#include "sdlButtonSala.h"
#include "sdlFont.h"
#include <sstream>

using std::string;
using std::stringstream;

sdlButtonSala::sdlButtonSala(){
	this->numSala = 0;
	this->nivel = 0;
	this->cantPlayers = 0;
	this->maxPlayers = 0;
}

sdlButtonSala::sdlButtonSala(unsigned num,unsigned lvl,unsigned plyrs,
unsigned maxplyrs){
	this->setDatos(num,lvl,plyrs,maxplyrs);
}

bool sdlButtonSala::load(string path){
	this->defaultImg.load(path);
	return sdlImage::load(path);
}

string sdlButtonSala::toString(unsigned numero){
	stringstream aux;
	aux << numero;
	return aux.str();
}

unsigned sdlButtonSala::getNumSala(){
	return this->numSala;
}

void sdlButtonSala::setDatos(unsigned num,unsigned lvl,unsigned plyrs,
unsigned maxplyrs){
	this->numSala = num;
	this->nivel = lvl;
	this->cantPlayers = plyrs;
	this->maxPlayers = maxplyrs;
	this->renderizar();
}

void sdlButtonSala::renderizar(){
    this->applySurface(0,0,this->defaultImg);
    sdlFont fuente("font.ttf", 20);
	sdlTextImage imagedNumber;
    imagedNumber.renderText(fuente,this->toString(numSala),ColorTextImage::verde);
	this->applySurface(95,0,imagedNumber);
	imagedNumber.renderText(fuente,this->toString(nivel),ColorTextImage::verde);
	this->applySurface(100,20,imagedNumber);
	imagedNumber.renderText(fuente,this->toString(cantPlayers),ColorTextImage::verde);
	this->applySurface(185,40,imagedNumber);
	imagedNumber.renderText(fuente,this->toString(maxPlayers),ColorTextImage::verde);
	this->applySurface(225,40,imagedNumber);
}
